/*
 * Copyright (c) 2015, the DeltaSync# project. All Rights Reserved.
 * This project is a C# port of the JDeltaSync project:
 *     http://jdeltasync.googlecode.com
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using System;
using System.Text;

/**
 * {@link Command} exchanged when an e-mail has been added.
 */
public class EmailAddCommand : Command {
    private string   id;
    private string   folderId;
    private DateTime dateReceived;
    private long     size;
    private bool     read;
    private bool     hasAttachments;
    private string   subject;
    private string   from;
    
    /**
     * Creates a new {@link Message}.
     * 
     * @param id the id.
     * @param dateReceived the {@link Date} and time when the message was 
     *        received.
     * @param size the size of the messages.
     * @param read <code>true</code> if the messages has been read, 
     *        <code>false</code> otherwise.
     * @param subject the message subject.
     * @param from the name and e-mail address of the sender.
     * @param hasAttachments <code>true</code> if the messages has attachments, 
     *        <code>false</code> otherwise.
     */
    public EmailAddCommand(string id, string folderId, DateTime dateReceived, long size, bool read,
            string subject, string from, bool hasAttachments) {
        this.id             = id;
        this.folderId       = folderId;
        this.dateReceived   = dateReceived;
        this.size           = size;
        this.read           = read;
        this.subject        = subject;
        this.from           = from;
        this.hasAttachments = hasAttachments;
    }

    /**
     * Returns the id of this {@link Message}.
     * 
     * @return the id.
     */
    public string Id {
        get { return id; }
    }

    public string FolderId {
        get { return folderId; }
    }
    
    /**
     * Returns the {@link Date} and time when this message was received.
     * 
     * @return the {@link Date} and time.
     */
    public DateTime DateReceived {
        get { return dateReceived; }
    }

    /**
     * Returns the size of this {@link Message} in bytes.
     * 
     * @return the size.
     */
    public long Size {
        get { return size; }
    }

    /**
     * Returns whether this {@link Message} has been read.
     * 
     * @return <code>true</code> if the messages has been read, 
     *         <code>false</code> otherwise.
     */
    public bool IsRead {
        get { return read; }
    }
    
    /**
     * Returns whether this {@link Message} has attachments.
     * 
     * @return <code>true</code> if the messages has attachments, 
     *         <code>false</code> otherwise.
     */
    public bool HasAttachments {
        get { return this.hasAttachments; }
    }

    /**
     * Returns the subject of this {@link Message}.
     * 
     * @return the subject.
     */
    public string Subject {
        get { return subject; }
    }

    /**
     * Returns the name and e-mail address of the person who sent this 
     * {@link Message}.
     * 
     * @return the sender name and e-mail.
     */
    public string From {
        get { return from; }
    }
    
    public override string ToString() {
        StringBuilder sb = new StringBuilder(base.ToString() + "(");
        sb.Append("id").Append("=").Append(id).Append(",");
        sb.Append("folderId").Append("=").Append(folderId).Append(",");
        sb.Append("dateReceived").Append("=").Append(dateReceived).Append(",");
        sb.Append("size").Append("=").Append(size).Append(",");
        sb.Append("read").Append("=").Append(read).Append(",");
        sb.Append("subject").Append("=").Append(subject).Append(",");
        sb.Append("from").Append("=").Append(from).Append(",");
        sb.Append("has attachments").Append("=").Append(hasAttachments);
        sb.Append(")");
        return sb.ToString();
    }
}
